import api from './base.js';
// 获取字典
export const getDict = ({ data = {}, callback }) => {
	// 乡镇（街道）：tree_local
	// 古树等级：sub_tree_lv
	// 认养情况：sub_tree_status
	// 认养人员类别：sub_person_type
	// 认捐人员类别：contribute_person_type
	api.init({
		url: '/admin-api/system/dict-data/page?pageNo=1&pageSize=10&label=&dictType=' + data.keyword,
		method: 'get',
		callback: res => {
			res.data = [
				...(res.data?.list || []).map(v => ({
					value: v.value,
					text: v.label,
				})),
			];
			try {
				callback(res);
			} catch (error) {}
		},
	});
};
// 上传用户头像
export const setAvatar = ({ data = {}, callback }) => {
	// Content-Type: multipart/form-data
	// avatarfile：文件
	api.init({
		url: '/system/user/profile/avatar',
		method: 'post',
		data,
		callback,
	});
};
// 部门列表
export const getDept = ({ callback }) => {
	api.init({
		url: '/admin-api/system/dept/simple-list',
		method: 'post',
		callback,
	});
};
